package com.example.bbfindhouse.Activity;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;

import com.example.bbfindhouse.Adapter.MessageAdapter;
import com.example.bbfindhouse.R;
import com.example.bbfindhouse.entity.Message;

import java.util.ArrayList;
import java.util.List;

public class MessageActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private MessageAdapter adapter;
    private List<Message> messages;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);

        recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        messages = new ArrayList<>();
        messages.add(new Message("用户5641", "老板这活干我接了", "11:12"));
        messages.add(new Message("房产顾问", "您好，关于您咨询的问题已经有新进展", "10:30"));
        messages.add(new Message("系统通知", "您有一条新的系统消息，请注意查看", "09:15"));

        adapter = new MessageAdapter(messages);
        recyclerView.setAdapter(adapter);

        // 找到底部导航栏的视图
        LinearLayout homeLayout = findViewById(R.id.home_nav_layout);
        LinearLayout messageLayout = findViewById(R.id.bottom_bar_message);
        LinearLayout wodeLayout = findViewById(R.id.bottom_bar_wode);

        // 为首页按钮添加点击事件监听器
        if (homeLayout != null) {
            homeLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // 跳转到首页
                    startActivity(new Intent(MessageActivity.this, IndexActivity.class));
                }
            });
        }

        // 为消息按钮添加点击事件监听器
        if (messageLayout != null) {
            messageLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // 跳转到消息页
                    startActivity(new Intent(MessageActivity.this, MessageActivity.class));
                }
            });
        }

        // 为个人中心按钮添加点击事件监听器
        if (wodeLayout != null) {
            wodeLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    // 跳转到个人中心页
                    startActivity(new Intent(MessageActivity.this, wodeActivity.class));
                }
            });
        }
    }
}